package com.imeth.cms.dao;



import com.imeth.base.MyBatisDao;
import com.imeth.cms.Picture;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 媒体
 * Created by huangcheng.dong on 2015/12/19.
 */
@MyBatisDao
public interface PictureDao {

    @Options(useGeneratedKeys=true, keyProperty="id")
    @Insert("insert into t_picture(uri,width,height,article_id) value(#{uri},#{width},#{height},#{articleId})")
    int save(Picture picture);

    @Delete("delete from t_picture where id=#{id}")
    int deleteById(Integer id);

    @Delete("delete from t_picture where article_id=#{id}")
    int deleteByArticleId(Integer id);

    @Results({
            @Result(column = "article_id", property = "articleId")
    })
    @Select("select * from t_picture where id=#{id}")
    Picture getById(Integer id);

    @Results({
            @Result(column = "article_id", property = "articleId")
    })
    @Select("select * from t_picture where article_id=#{id}")
    List<Picture> queryByArticleId(Integer id);
}